package fr.paris.sud.com;

import java.awt.Color;
import java.awt.geom.Point2D;

import fr.lri.swingstates.canvas.CElement;
import fr.lri.swingstates.canvas.CImage;
import fr.paris.sud.com.GridNode;

class GridNode{
	CElement vis;
	int index;
	ImageStructure imageAttached;
	//Point2D point;
	public GridNode(Point2D point, int index){
		this.index = index;
		this.vis = PhotoManagerWindow.canvas.newRectangle(point.getX()-64, point.getY()-64, 128, 128);
		this.vis.setTransparencyFill(0.1f);
		this.vis.setOutlinePaint(Color.black);
		this.vis.addTag("gridNode");
	}

	public void highlight(){
		vis.setFillPaint(Color.RED);
	}

	public void unhighlight(){
		vis.setFillPaint(Color.GRAY);
	}

	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (obj == this)
			return true;
		if (!(obj instanceof GridNode))
			return false;

		GridNode rhs = (GridNode) obj;
		return rhs.vis.getCenterX() == (this.vis.getCenterX()) && rhs.vis.getCenterY() == (this.vis.getCenterY());
	}
	
	public void attachImage(ImageStructure img){
		this.imageAttached = img;
	}
	
	public ImageStructure getAttachedImage(){
		return imageAttached;
	}

}